#!/bin/bash

# simple script to cross-build gdb for riscv64
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin

../configure --prefix=/opt/riscv64 --build=x86_64-linux-gnu --host=x86_64-linux-gnu \
	--target=riscv64-linux-gnu --enable-year2038 --enable-lto --enable-host-shared \
	--with-system-zlib CC=gcc CFLAGS'-Wall -fPIC -D_GNU_SOURCE -O2 -fno-omit-frame-pointer' \
	LDFLAGS='-L/opt/riscv64/lib -Wl,-rpath=/opt/riscv64/lib' CXX=g++ \
	CXXFLAGS='-Wall -fPIC -D_GNU_SOURCE -O2 -fno-omit-frame-pointer' --with-python=/usr/bin/python3 \
	AR=ar LD=gcc NM=nm RANLIB=ranlib STRIP=strip OBJCOPY=objcopy READELF=readelf
[ $? -eq 0 ] && exec make V=1 -j4
